package com.shopmall.controller.goods;


import com.shopmall.common.ResponseData;
import com.shopmall.goods.entity.GoodsClassify;
import com.shopmall.goods.service.IGoodsClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/classify")
public class GoodsClassifyController extends ResponseData {
    @Autowired
    private IGoodsClassifyService goodsClassifyService;

    @PostMapping("list")
    public ResponseData materialPageList(@RequestBody GoodsClassify goodsClassify){
        return success(goodsClassifyService.classifyList(goodsClassify));
    }

    @PostMapping("addOrUpdate")
    public ResponseData addOrUpdate(@RequestBody GoodsClassify goodsClassify){
        int i = goodsClassifyService.addOrUpdateClassify(goodsClassify);
        if(i>0){
            return success("成功");
        }
        return failed("失败");
    }

    @GetMapping("/getClassify")
    public ResponseData getClassify(){
        return success(goodsClassifyService.getClassify());
    }
}
